package com.lepu.app.fun.chat.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class BeanLectureChatUser implements Serializable{


    public String UserID;
    public String NickName; //昵称
    public String Avatar;
    public String UserRank;//用户等级。  管理员的身份由2
    public String UserRankTitle ;// 用户类别 普通用户，
    public String NickNameInitials;  //显示数据拼音的首字母

    public static ArrayList<BeanLectureChatUser> parseListInfo(String dataString) {
        String result = "";
        try {
            JSONObject jsonObject = new JSONObject(dataString);
            JSONObject obj1 = (JSONObject) jsonObject.get("Result");
            JSONArray jsonArray = obj1.getJSONArray("ListInfo");

            result = jsonArray.toString();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Gson gson = new Gson();
        ArrayList<BeanLectureChatUser> dataList = gson.fromJson(result,
                new TypeToken<List<BeanLectureChatUser>>() {
                }.getType());
        return dataList;
    }

    /*
     * 解析数据
     */
    public static BeanLectureChatUser parseDetailInfo(String dataString) {
        String result = "";
        try {
            JSONObject jsonObject = new JSONObject(dataString);
            JSONObject obj1 = (JSONObject) jsonObject.get("Result");
            JSONObject obj2 = (JSONObject) obj1.get("groupMemberDetail");

            result = obj2.toString();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Gson gson = new Gson();
        BeanLectureChatUser item = gson.fromJson(result,
                new TypeToken<BeanLectureChatUser>() {
                }.getType());
        return item;
    }
}
